package com.xiaozhuai.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
public class ModelTest1 {

    @RequestMapping("/m1/t1")
    public String test1(HttpServletRequest res, HttpServletResponse resp){
        HttpSession session =res.getSession();
        System.out.println(session.getId());
        return "hello";
    }

    @RequestMapping("/m1/t2")
    public String test2(Model model){
        model.addAttribute("msg","ModelTest1,forward");
        return "forward:/WEB-INF/jsp/hello.jsp";
    }

    @RequestMapping("/m1/t3")
    public String test3(Model model){
        model.addAttribute("msg","ModelTest1,redirect");
        return "redirect:/index.jsp";
    }

    //过滤器解决乱码问题
    @RequestMapping("/e/t1")
    public String test4(String str, Model model){
        model.addAttribute("msg",str);
        return "test";
    }
}
